const app = getApp()


Page({
  data: {
    rate: 1,
    items: [
      { name: 1, value: '简单', checked: 'true' },
      { name: 2, value: '中等' },
      { name: 3, value: '困难' }
    ]
  },
  radioChange: function (e) {
    console.log('radio发生change事件，携带value值为：', e.detail.value)
    let rate = parseInt(e.detail.value);
    this.setData({
      rate: rate
    })
  },
  countInput(e) {
    console.log('countInput', e)
    let count = parseInt(e.detail.value);
    if (count > 100) {
      wx.showModal({
        title: '提示',
        content: '最大测试数量为100道！',
        showCancel: false
      })
      count = 100;
    } else if (count < 1) {
      wx.showModal({
        title: '提示',
        content: '请输入大于等于1的值！',
        showCancel: false
      })
      count = 5;
    }
    this.setData({
      count: count
    })
  },
  formSubmit: function (e) {
    var that = this;
    var count = this.data.count;
    var rate = this.data.rate;
    if (!count) {
      wx.showModal({
        title: '提示',
        content: '未设置测试数量！',
        showCancel: false
      })
    } else {
      wx.navigateTo({
        url: '/pages/question/question?count=' + count + '&rate=' + rate,
      })
    }
  }
})